<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var isLongPressedName = function (name, typed) {
      let i = 0, j = 0
      while (j < typed.length) {
        if (name[i] !== typed[j])
          if (typed[j] === typed[j - 1]) j++
          else return false
        else i++, j++
      }
      return name[i] === name[j]
    };
    console.log(isLongPressedName("alex", "aaleex"))
  </script>
</body>

</html>